package com.betterjr.modules.profit;

import com.betterjr.common.web.Servlets;
import com.alibaba.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import static com.betterjr.common.web.ControllerExceptionHandler.exec;

/**
 * Created by chenlj on 2018/6/27
 */
@Controller
@RequestMapping(value = "/Scf/LoanService")
public class ScfLoanServiceController {
    private static final Logger logger = LoggerFactory.getLogger(ScfLoanServiceController.class);

    @Reference(interfaceClass = IScfProfitService.class)
    private  IScfProfitService scfProfitService;

    @RequestMapping(value = "/queryLoanServiceList", method = RequestMethod.POST)
    public @ResponseBody String queryLoanServiceList(HttpServletRequest request, int flag, int pageNum, int pageSize) {
        Map<String, Object> map = Servlets.getParametersStartingWith(request, "");
        logger.info("分页查询服务费，入参：" + map.toString());
        return exec(() -> scfProfitService.webQueryLoanServiceList(map, flag, pageNum, pageSize), "查询服务费失败" ,logger);
    }

    @RequestMapping(value = "/saveUpdateLoanServiceStatus", method = RequestMethod.POST)
    public @ResponseBody String saveUpdateLoanServiceStatus(HttpServletRequest request) {
        Map<String, Object> map = Servlets.getParametersStartingWith(request, "");
        logger.info("改变服务费明细状态，入参：" + map.toString());
        return exec(() -> scfProfitService.webSaveConfirmLoanServiceStatus(map), "改变服务费明细状态失败", logger);
    }

}
